/**
 * 
 */
<div>
  <span>
    <a></a>
  </span>
  <span>
    <a></a>
    <a></a>
  </span>
</div>
function dom2Json(domtree) {
  let obj = {
    name: domtree.tagName,
    children: [],
  };
  domtree.childNodes.forEach((child) => obj.children.push(dom2Json(child)));
  return obj;
}
function dom2json(domNode) {
  const {tagName, attributes, childNodes} = domNode;
  const vnode = {
    tag: tagName,
    attrs: {},
    children: [],
  }
  if(attributes) {
    for(let attr of attributes) {
      vnode.attrs[attr.name] = attr.value;
    }
  }
  if(childNodes) {
    for(let child of childNodes) {
      const childNode = dom2json(child);
      vnode.children.push(childNode);
    }
  }
  return vnode;
}